SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO


CREATE PROCEDURE dbo.DnnProduct_UpdateServerActivity
    @ServerName			nvarchar(50),
    @IISAppName			nvarchar(200),
    @CreatedDate		datetime,
    @LastActivityDate	datetime 
AS

	DECLARE @ServerID int
	SET @ServerID = (SELECT ServerID FROM dbo.DnnProduct_WebServers WHERE ServerName = @ServerName AND IISAppName = @IISAppName)

	IF @ServerID IS NULL
		BEGIN
			-- Insert
			INSERT INTO dbo.DnnProduct_WebServers (
				ServerName,
				IISAppName,
				CreatedDate,
				LastActivityDate,
				[Enabled]
			)
			VALUES (
				@ServerName,
				@IISAppName,
				@CreatedDate,
				@LastActivityDate,
				0
			)
		END
	ELSE
		BEGIN
			-- Update
			UPDATE dbo.DnnProduct_WebServers 
				SET 
					LastActivityDate = @LastActivityDate
				WHERE  ServerName = @ServerName AND IISAppName = @IISAppName
		END
GO
